package com.kingdee.eas.jky.pm.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;
import java.math.BigDecimal;

import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.DefineProjectFactory;
import com.kingdee.eas.custom.DefineProjectInfo;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.jky.enums.BudgetEnum;
import com.kingdee.eas.jky.enums.ProjectEnum;
import com.kingdee.eas.jky.pm.ProjectBudgetInfo;
import com.kingdee.eas.jky.pm.SafetyPectionInfo;
import com.kingdee.eas.jky.pm.SafetyPectionCollection;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SorterItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.xr.XRBillBaseCollection;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.eas.xr.app.XRBillBaseControllerBean;
import com.kingdee.eas.framework.CoreBillBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ObjectBaseCollection;

public class SafetyPectionControllerBean extends AbstractSafetyPectionControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.jky.pm.app.SafetyPectionControllerBean");
    protected void _audit(Context ctx, IObjectPK pk)throws BOSException, EASBizException
    {
         super._audit(ctx, pk);
         SafetyPectionInfo saftInfo = (SafetyPectionInfo) this.getValue(ctx, pk);
         if(saftInfo.getProjectNumber()!=null){
        	 String projectID=saftInfo.getProjectNumber().getId().toString();
        	 DefineProjectInfo projectInfo= DefineProjectFactory.getLocalInstance(ctx).getDefineProjectInfo(new ObjectUuidPK(projectID));
        	 projectInfo.setAqCounts(projectInfo.getAqCounts()+1);
        	 DefineProjectFactory.getLocalInstance(ctx).update(new ObjectUuidPK(projectID), projectInfo);
         }
         
    }
    protected void _unAudit(Context ctx, IObjectPK pk)throws BOSException, EASBizException
    {
         super._unAudit(ctx, pk);
         SafetyPectionInfo saftInfo = (SafetyPectionInfo) this.getValue(ctx, pk);
         if(saftInfo.getProjectNumber()!=null){
        	 String projectID=saftInfo.getProjectNumber().getId().toString();
        	 DefineProjectInfo projectInfo= DefineProjectFactory.getLocalInstance(ctx).getDefineProjectInfo(new ObjectUuidPK(projectID));
        	 projectInfo.setAqCounts(projectInfo.getAqCounts()-1);
        	 DefineProjectFactory.getLocalInstance(ctx).update(new ObjectUuidPK(projectID), projectInfo);
         }
    }
    protected void _unAudit(Context ctx, IObjectPK[] pks)throws BOSException, EASBizException
    {
         super._unAudit(ctx, pks);
         for(int i=0;i<pks.length;i++){
        	 SafetyPectionInfo saftInfo = (SafetyPectionInfo) this.getValue(ctx, pks[i]);
      		 if(saftInfo.getProjectNumber()!=null){
             	 String projectID=saftInfo.getProjectNumber().getId().toString();
             	 DefineProjectInfo projectInfo= DefineProjectFactory.getLocalInstance(ctx).getDefineProjectInfo(new ObjectUuidPK(projectID));
             	 projectInfo.setAqCounts(projectInfo.getAqCounts()-1);
             	 DefineProjectFactory.getLocalInstance(ctx).update(new ObjectUuidPK(projectID), projectInfo);
 		     }
      	}
    }
}